package com.zjj.io.recursion;

/**
 * @author zhoujunjie
 * @desc TODO
 * @date
 */

public class RecursionTest2 {

    static int buyNum = 0;
    static int beerCap = 0;
    static int beerBottle = 0;
    public static void main(String[] args) {
        buyBeer(10);
        System.out.println("啤酒购买数量 = "+buyNum);
        System.out.println("剩余空瓶子数量 = "+beerBottle);
        System.out.println("剩余啤酒盖数量 = "+beerCap);
    }

    public static void buyBeer(int money){
        int num = money/2;
        buyNum+=num;
        beerBottle+=num;
        beerCap+=num;
        int changeMoney = beerBottle/2*2;
        changeMoney+=beerCap/4*2;
        beerBottle%=2;
        beerCap%=4;
        if(changeMoney>=2){
            buyBeer(changeMoney);
        }
    }

}
